package com.ruoyi.cencat.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.cencat.domain.CencatRepoAdmin;
import com.ruoyi.cencat.service.ICencatRepoAdminService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 仓库管理员信息Controller
 * 
 * @author cencat
 * @date 2024-05-21
 */
@RestController
@RequestMapping("/cencat/admin")
public class CencatRepoAdminController extends BaseController
{
    @Autowired
    private ICencatRepoAdminService cencatRepoAdminService;

    /**
     * 查询仓库管理员信息列表
     */
    @PreAuthorize("@ss.hasPermi('cencat:admin:list')")
    @GetMapping("/list")
    public TableDataInfo list(CencatRepoAdmin cencatRepoAdmin)
    {
        startPage();
        List<CencatRepoAdmin> list = cencatRepoAdminService.selectCencatRepoAdminList(cencatRepoAdmin);
        return getDataTable(list);
    }

    /**
     * 导出仓库管理员信息列表
     */
    @PreAuthorize("@ss.hasPermi('cencat:admin:export')")
    @Log(title = "仓库管理员信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CencatRepoAdmin cencatRepoAdmin)
    {
        List<CencatRepoAdmin> list = cencatRepoAdminService.selectCencatRepoAdminList(cencatRepoAdmin);
        ExcelUtil<CencatRepoAdmin> util = new ExcelUtil<CencatRepoAdmin>(CencatRepoAdmin.class);
        util.exportExcel(response, list, "仓库管理员信息数据");
    }

    /**
     * 获取仓库管理员信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('cencat:admin:query')")
    @GetMapping(value = "/{repoAdminId}")
    public AjaxResult getInfo(@PathVariable("repoAdminId") Long repoAdminId)
    {
        return success(cencatRepoAdminService.selectCencatRepoAdminByRepoAdminId(repoAdminId));
    }

    /**
     * 新增仓库管理员信息
     */
    @PreAuthorize("@ss.hasPermi('cencat:admin:add')")
    @Log(title = "仓库管理员信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CencatRepoAdmin cencatRepoAdmin)
    {
        return toAjax(cencatRepoAdminService.insertCencatRepoAdmin(cencatRepoAdmin));
    }

    /**
     * 修改仓库管理员信息
     */
    @PreAuthorize("@ss.hasPermi('cencat:admin:edit')")
    @Log(title = "仓库管理员信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CencatRepoAdmin cencatRepoAdmin)
    {
        return toAjax(cencatRepoAdminService.updateCencatRepoAdmin(cencatRepoAdmin));
    }

    /**
     * 删除仓库管理员信息
     */
    @PreAuthorize("@ss.hasPermi('cencat:admin:remove')")
    @Log(title = "仓库管理员信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{repoAdminIds}")
    public AjaxResult remove(@PathVariable Long[] repoAdminIds)
    {
        return toAjax(cencatRepoAdminService.deleteCencatRepoAdminByRepoAdminIds(repoAdminIds));
    }
}
